package com.classroom;

public class ReplaceAllDemo {
    public static void main(String[] args) {
        /**
         * replaceAll(String regex, String replacement)
         * 替换每个子字符串的字符串匹配给定 regular expression用给定的替代品。
         */
        String line = "abc123klo987";
        String str = line.replaceAll("[0-9]+", "number");
        System.out.println("str = " + str);


        /**
         * 实际开发的应用
         */
        String string = "wqnmlgb|cnm|dsb|nc|mdzz|nmsl|djb";
        String message = "wqnmlgb!你个dsb!你怎么这么nc!你就一个djb!";
        message = message.replaceAll(string, "***");
        System.out.println("message = " + message);
    }
}
